# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallAction do
  @moduledoc """
  An individual action. Each action represents what to do if a policy matches.

  ## Attributes

  *   `allow` (*type:* `GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionAllowAction.t`, *default:* `nil`) - The user request did not match any policy and should be allowed access to the requested resource.
  *   `block` (*type:* `GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionBlockAction.t`, *default:* `nil`) - This action denies access to a given page. The user gets an HTTP error code.
  *   `includeRecaptchaScript` (*type:* `GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionIncludeRecaptchaScriptAction.t`, *default:* `nil`) - This action injects reCAPTCHA JavaScript code into the HTML page returned by the site backend.
  *   `redirect` (*type:* `GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectAction.t`, *default:* `nil`) - This action redirects the request to a reCAPTCHA interstitial to attach a token.
  *   `setHeader` (*type:* `GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction.t`, *default:* `nil`) - This action sets a custom header but allow the request to continue to the customer backend.
  *   `substitute` (*type:* `GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteAction.t`, *default:* `nil`) - This action transparently serves a different page to an offending user.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :allow =>
            GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionAllowAction.t()
            | nil,
          :block =>
            GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionBlockAction.t()
            | nil,
          :includeRecaptchaScript =>
            GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionIncludeRecaptchaScriptAction.t()
            | nil,
          :redirect =>
            GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectAction.t()
            | nil,
          :setHeader =>
            GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction.t()
            | nil,
          :substitute =>
            GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteAction.t()
            | nil
        }

  field(:allow,
    as:
      GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionAllowAction
  )

  field(:block,
    as:
      GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionBlockAction
  )

  field(:includeRecaptchaScript,
    as:
      GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionIncludeRecaptchaScriptAction
  )

  field(:redirect,
    as:
      GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectAction
  )

  field(:setHeader,
    as:
      GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction
  )

  field(:substitute,
    as:
      GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteAction
  )
end

defimpl Poison.Decoder,
  for: GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallAction do
  def decode(value, options) do
    GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallAction.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.RecaptchaEnterprise.V1.Model.GoogleCloudRecaptchaenterpriseV1FirewallAction do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
